package com.scisoft.scan.control.check;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.scisoft.scan.dy.R;
import com.scisoft.scan.data.check.CheckOrderBean;

import java.util.List;

public class CheckOrderAdapter extends BaseAdapter {
    private List<CheckOrderBean> checkOrderBeanList;//数据源
    private LayoutInflater mInflater;//布局装载器对象
    private Context mContext;

    public CheckOrderAdapter(List<CheckOrderBean> checkOrderBeanList, Context context) {
        this.checkOrderBeanList = checkOrderBeanList;
        mInflater = LayoutInflater.from(context);
        mContext = context;
    }
    @Override
    public int getCount() {
        //return返回的是int类型，也就是页面要显示的数量。
        return checkOrderBeanList.size();
    }
    @Override
    public Object getItem(int position) {
        return checkOrderBeanList.get(position);
    }
    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        //将布局文件转化为View对象
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.item_checkorder,null);
        }
        //盘点单号
        TextView tv_orderNo = convertView.findViewById(R.id.tv_orderNo);
        //盘点件数量
        TextView tv_typeCount= convertView.findViewById(R.id.tv_typeCount);
        //仓库
        TextView tv_depot= convertView.findViewById(R.id.tv_depot);
        //时间
        TextView tv_date = convertView.findViewById(R.id.tv_date);
        //操作员
        TextView tv_operator = convertView.findViewById(R.id.tv_operator);
        //实盘数量
        TextView tv_checkCount = convertView.findViewById(R.id.tv_checkCount);
        //账面数量
        TextView tv_allCount = convertView.findViewById(R.id.tv_allCount);
        //状态
        TextView tv_state = convertView.findViewById(R.id.tv_state);
        //库区
        TextView tv_area = convertView.findViewById(R.id.tv_area);

        //获取相应索引的ItemBean对象
        CheckOrderBean bean = checkOrderBeanList.get(position);

        //设置控件的对应属性值
        tv_orderNo.setText(bean.orderNo);
        tv_typeCount.setText(String.valueOf(bean.typeCount) + "品种");
        tv_depot.setText(bean.depotName);
        tv_operator.setText(bean.operator);
        tv_date.setText(bean.optime);
        tv_checkCount.setText(String.valueOf(bean.checkCount));
        tv_allCount.setText(String.valueOf(bean.allCount));
        tv_area.setText(bean.reservoirArea);

        return convertView;
    }
}
